package thss.lau.secretshare;

import java.math.BigInteger;

public class Equation {
	private BigInteger[] coefficients;

	public Equation(BigInteger[] coefficients) {
		this.coefficients = coefficients;
	}

	public BigInteger getValue(BigInteger x) {
		BigInteger value = coefficients[0];
		for (int i = 1; i < coefficients.length; i++) {
			value=value.add(coefficients[i].multiply(x.pow(i)));
		}
		return value;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		for(int i=0; i<coefficients.length; i++){
			sb.append(i+": ");
			sb.append(coefficients[i].toString()+ "\n");
		}
		return sb.toString();
	}
}
